import pandas as pd
import matplotlib.pyplot as plt
file_path=r'C:\Users\Administrator\PycharmProjects\pythonProject\男子体能测试成绩.xlsx'
data=pd.read_excel(file_path)
grades=data['成绩等级']
grade_counts=grades.value_counts()
plt.figure(figsize=(8,8))
plt.pie(grade_counts,autopct='%1.1f%%',startangle=90,pctdistance=0.9,textprops={'fontsize':13,'color':'w'})
plt.title('男子体能测试成绩等级占比饼图',fontsize=20)
plt.rcParams['font.sans-serif']='SimHei'
plt.legend(grade_counts.index)
plt.show()